<?php
namespace BoxSns\Widget;
class TopicWidget extends \WidgetController {

	//话题列表
	public function topicList($p) {
		//dump($p['where']);
		$this->params = $p;
		$p['where']['is_show'] = 1;
		$p['where']['type'] = $p['type'];
		$data = BoxModel("sns_topic")->get($p['where'], $p['limit'] ? $p['limit'] : 10, "lastupdate desc");
		//	dump(BoxModel("sns_topic"));
		$this->data = $data['list'];
		$this->count = intval($data['count']);
		$this->show_page($data['pager']);
		$this->display();
	}

	public function add($p) {
		$this->params = $p;
		$this->display();
	}

	//话题提交
	public function addTopic($p) {
		$this->display();
	}

	//查看话题
	public function showTopic($p) {
		$this->topic_id = $p['topic_id'];
		$this->params = $p;
		$this->data = BoxModel("sns_topic")->load($this->topic_id);
		// dump($this->data);
		$this->display();
	}

	//评论列表
	public function commentList($p) {
		$this->params = $p;
		$this->topic_id = $p['topic_id'];
		//dump($p);
		$this->topic_info = BoxModel("sns_topic")->where(array('id' => $this->topic_id))->find();
		//dump(	$this->topic_info);
		$data = Logic("BoxSns", "Comment")->get(array('topic_id' => $this->topic_id, 'type' => $p['type'], 'limit' => 10, 'orderBy' => $p['orderBy']));
		$this->data = $data['list'];
		$this->count = intval($data['count']);
		$this->show_page($data['pager']);
		$this->display();
	}

	//添加评论
	public function addComment($p) {
		$this->display();
	}

	//添加评论
	function wapAddComment($p) {
		$this->param = $p;
		$this->display();
	}

}